﻿<sdk:Page x:Class="SampleBrowser.Views.SampleDeepZoomViewer" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:doc="http://schemas.firstfloorsoftware.com/documenttoolkit"
           xmlns:dte="http://schemas.firstfloorsoftware.com/documenttoolkit/extensions"
           xmlns:behaviors="clr-namespace:SampleBrowser.Behaviors"
           xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Deep Zoom Document Viewer">
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" Text="Deep Zoom Document Viewer"/>
        <TextBlock Grid.Row="1" Text="Navigate a document in a deep zoom like manner. Use the mouse for panning and zooming." />

        <Grid Grid.Row="2" Margin="8">
            <doc:DocumentDataSource x:Name="DataSource" />
            <dte:ScaleDocumentViewer x:Name="Viewer" DocumentDataSource="{Binding ElementName=DataSource}" ViewportOrigin="-.5,-.1" ViewportWidth="2"
                                     Background="{StaticResource NormalBrush}"
                                     BorderBrush="{StaticResource SliderTrackBrush}"
                                     BorderThickness="1">
                <i:Interaction.Behaviors>
                    <dte:ScaleDocumentViewerMouseBehavior x:Name="ViewerBehavior" />
                </i:Interaction.Behaviors>
            </dte:ScaleDocumentViewer>
        </Grid>

        <StackPanel Grid.Row="3" Orientation="Horizontal" Margin="8" >
            <Button Margin="4,0,0,0" Padding="7" VerticalAlignment="Center">
                <Button.Command>
                    <dte:OpenPdfOrXpsFromDiskCommand DocumentDataSource="{Binding ElementName=DataSource}" />
                </Button.Command>
                <Button.Content>
                    <Image Source="/SampleBrowser;component/Assets/Icons/open.png" />
                </Button.Content>
            </Button>
            <doc:PageNavigator PageCount="{Binding PageCount, ElementName=Viewer}" PageIndex="{Binding PageIndex, ElementName=Viewer, Mode=TwoWay}" VerticalAlignment="Center"/>

            <CheckBox Margin="16,0,0,0" IsChecked="{Binding UseSprings, ElementName=Viewer, Mode=TwoWay}" Content="UseSprings" VerticalAlignment="Center" />

            <TextBlock Margin="16,0,0,0">
                    <Run Text="ViewportOrigin:" />
                    <Run Text="{Binding ViewportOrigin.X, ElementName=Viewer, StringFormat=0.###}" /><Run Text="x" /><Run Text="{Binding ViewportOrigin.Y, ElementName=Viewer, StringFormat=0.###}" />
                    <LineBreak />
                    <Run Text="ViewportWidth:" />
                    <Run Text="{Binding ViewportWidth, ElementName=Viewer, StringFormat=0.###}" />
            </TextBlock>
            <TextBlock Margin="16,0,0,0">
                    <Run Text="AspectRatio:" />
                    <Run Text="{Binding AspectRatio, ElementName=Viewer, StringFormat=0.###}" />
            </TextBlock>
            <TextBlock Margin="16,0,0,0">
                    <Run Text="LogicalMousePos:" />
                    <Run Text="{Binding LogicalMousePosition.X, ElementName=ViewerBehavior, StringFormat=0.###}" /><Run Text="x" /><Run Text="{Binding LogicalMousePosition.Y, ElementName=ViewerBehavior, StringFormat=0.###}" />
            </TextBlock>
        </StackPanel>
    </Grid>
</sdk:Page>
